package org.study.neo4j.boot.repository;

import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.query.Query;
import org.springframework.data.repository.query.Param;
import org.study.neo4j.boot.model.Course;

import java.util.List;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年04月09日
 */
public interface CourseRepository extends Neo4jRepository<Course, Long> {
    Course findByCode(String code);

    @Query("MATCH (c:Course)<-[:TEACHES]-(t:Teacher) WHERE t.name = $teacherName RETURN c")
    List<Course> findByTeacherName(@Param("teacherName") String teacherName);

    @Query("MATCH (c:Course)<-[:ENROLLED_IN]-(s:Student) WHERE s.name = $studentName RETURN c")
    List<Course> findByStudentName(@Param("studentName") String studentName);

    void deleteByCode(String code);
}
